document.addEventListener('DOMContentLoaded', () => {
//
//
//     // Header search functionality
    const headerSearch = document.getElementById('header-search');
    const headerSearchBtn = document.getElementById('header-search-btn');

//重定型到select类并且返回文本框内容“query”
    function performSearch() {
        const searchTerm = headerSearch.value.trim();
        if (searchTerm) {
            const searchUrl = `Select?keyword=${encodeURIComponent(searchTerm)}&style=3`;
            window.location.href = searchUrl;
        }
    }

    headerSearchBtn.addEventListener('click', performSearch);
    headerSearch.addEventListener('keyup', (e) => {
        if (e.key === 'Enter') {
            performSearch();
        }
    });

    headerSearchBtn.addEventListener('click', performSearch);
    headerSearch.addEventListener('keyup', (e) => {
        if (e.key === 'Enter') {
            performSearch();
        }
    });

});


//Login
document.addEventListener('DOMContentLoaded', function () {
    document.body.addEventListener('click', function (event) {
        if (event.target.classList.contains('login-up')) {
            // 登录按钮点击后要执行的代码
            // alert('登录按钮被点击了！');
            window.location.href = 'Login';
        } else if (event.target.classList.contains('publish-btn')){
            window.location.href="Insert"
        }
    });
});
document.addEventListener('DOMContentLoaded', () => {
    const userIcon = document.querySelector('.user-icon');
    const loginList = document.querySelector('.Loginlist');

    userIcon.addEventListener('click', () => {
        // 使用 'toggle' 方法简化显示和隐藏逻辑
        loginList.style.display = loginList.style.display === 'none' ? 'block' : 'none';
    });
});




